package com.ruoyi.web.service.impl;

import java.util.List;
import com.ruoyi.common.utils.ShiroUtils;
import com.ruoyi.common.utils.DateUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import com.ruoyi.web.mapper.OldDrugDiseaseMapper;
import com.ruoyi.web.domain.OldDrugDisease;
import com.ruoyi.web.service.IOldDrugDiseaseService;
import com.ruoyi.common.core.text.Convert;

/**
 * 药品疾病关联Service业务层处理
 * 
 * @author drx
 * @date 2024-03-06
 */
@Service
public class OldDrugDiseaseServiceImpl implements IOldDrugDiseaseService 
{
    @Autowired
    private OldDrugDiseaseMapper oldDrugDiseaseMapper;

    /**
     * 查询药品疾病关联
     * 
     * @param id 药品疾病关联主键
     * @return 药品疾病关联
     */
    @Override
    public OldDrugDisease selectOldDrugDiseaseById(Long id)
    {
        return oldDrugDiseaseMapper.selectOldDrugDiseaseById(id);
    }

    /**
     * 查询药品疾病关联列表
     * 
     * @param oldDrugDisease 药品疾病关联
     * @return 药品疾病关联
     */
    @Override
    public List<OldDrugDisease> selectOldDrugDiseaseList(OldDrugDisease oldDrugDisease)
    {
        return oldDrugDiseaseMapper.selectOldDrugDiseaseList(oldDrugDisease);
    }

    /**
     * 新增药品疾病关联
     * 
     * @param oldDrugDisease 药品疾病关联
     * @return 结果
     */
    @Override
    public int insertOldDrugDisease(OldDrugDisease oldDrugDisease)
    {
        oldDrugDisease.setCreateTime(DateUtils.getNowDate());
        oldDrugDisease.setCreateBy(ShiroUtils.getSysUser().getLoginName());
        return oldDrugDiseaseMapper.insertOldDrugDisease(oldDrugDisease);
    }

    /**
     * 修改药品疾病关联
     * 
     * @param oldDrugDisease 药品疾病关联
     * @return 结果
     */
    @Override
    public int updateOldDrugDisease(OldDrugDisease oldDrugDisease)
    {
        oldDrugDisease.setUpdateTime(DateUtils.getNowDate());
        oldDrugDisease.setUpdateBy(ShiroUtils.getSysUser().getLoginName());
        return oldDrugDiseaseMapper.updateOldDrugDisease(oldDrugDisease);
    }

    /**
     * 批量删除药品疾病关联
     * 
     * @param ids 需要删除的药品疾病关联主键
     * @return 结果
     */
    @Override
    public int deleteOldDrugDiseaseByIds(String ids)
    {
        return oldDrugDiseaseMapper.deleteOldDrugDiseaseByIds(Convert.toStrArray(ids),ShiroUtils.getSysUser().getLoginName());
    }

    /**
     * 删除药品疾病关联信息
     * 
     * @param id 药品疾病关联主键
     * @return 结果
     */
    @Override
    public int deleteOldDrugDiseaseById(Long id)
    {
        return oldDrugDiseaseMapper.deleteOldDrugDiseaseById(id,ShiroUtils.getSysUser().getLoginName());
    }

    /**
     * 删除药品疾病关联信息
     *
     * @param drugId 药品疾病关联主键
     * @return 结果
     */
    public int deleteOldDrugDiseaseByDrugId(Long drugId)
    {
        return oldDrugDiseaseMapper.deleteOldDrugDiseaseByDrugId(drugId,ShiroUtils.getSysUser().getLoginName());
    }
}
